import { S } from '../../s';
import { IPSAppDEACMode } from '../../app/dataentity/ipsapp-deacmode';
import { IPSAppDEDataSet } from '../../app/dataentity/ipsapp-dedata-set';
import { IPSAppDataEntity } from '../../app/dataentity/ipsapp-data-entity';
import { IPSAppView } from '../../app/view/ipsapp-view';
import { IPSAutoComplete } from './ipsauto-complete';
import { IPSPickerEditor } from './ipspicker-editor';
import { PSValueItemEditorImpl } from './psvalue-item-editor-impl';
import { IPSUIActionGroup } from '../../view/ipsuiaction-group';

export class PSPickerEditorImpl
  extends PSValueItemEditorImpl
  implements IPSPickerEditor, IPSAutoComplete
{
  get aCMinChars(): number {
    return this.M.aCMinChars != null ? this.M.aCMinChars : 0;
  }

  get contextJOString(): string {
    return this.M.contextJOString;
  }

  get handlerType(): string {
    return this.M.handlerType;
  }

  get itemParamJO(): IModel {
    return this.M.itemParamJO;
  }

  protected psappdeacmode: IPSAppDEACMode;
  getPSAppDEACMode(): IPSAppDEACMode | null {
    if (this.psappdeacmode != null) return this.psappdeacmode;
    const value = this.M.getPSAppDEACMode;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.psappdeacmode = ipsappdataentity.findPSAppDEACMode(value);
    }
    return this.psappdeacmode;
  }

  protected psappdedataset: IPSAppDEDataSet;
  getPSAppDEDataSet(): IPSAppDEDataSet | null {
    if (this.psappdedataset != null) return this.psappdedataset;
    const value = this.M.getPSAppDEDataSet;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.psappdedataset = ipsappdataentity.findPSAppDEDataSet(value);
    }
    return this.psappdedataset;
  }

  protected psappdataentity: IPSAppDataEntity;
  getPSAppDataEntity(): IPSAppDataEntity | null {
    return (
      this.psappdataentity ||
      (this.psappdataentity = this.fillObjectModel(
        S._f,
        this.M.getPSAppDataEntity,
        S._2aa,
      ) as IPSAppDataEntity)
    );
  }

  protected psuiactiongroup: IPSUIActionGroup;
  getPSUIActionGroup(): IPSUIActionGroup | null {
    return (
      this.psuiactiongroup ||
      (this.psuiactiongroup = this.fillObjectModel(
        S._210,
        this.M.getPSUIActionGroup,
        S._2ed,
      ) as IPSUIActionGroup)
    );
  }

  get paramJOString(): string {
    return this.M.paramJOString;
  }

  protected pickuppsappview: IPSAppView;
  getPickupPSAppView(): IPSAppView | null {
    return (
      this.pickuppsappview ||
      (this.pickuppsappview = this.fillObjectModel(
        S._1e,
        this.M.getPickupPSAppView,
        S._316,
      ) as IPSAppView)
    );
  }

  get enableAC(): boolean {
    return this.M.enableAC;
  }

  get enablePickupView(): boolean {
    return this.M.enablePickupView;
  }

  get forceSelection(): boolean {
    return this.M.forceSelection;
  }

  get showTrigger(): boolean {
    return this.M.showTrigger;
  }
  get cls(): string {
    return 'PSPickerEditorImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._146 || cls == S._7 || cls == S._147 || cls == S._148)
      return true;
    return super.instanceof(cls);
  }
}
